<template>

  <div class="loading">
    <img src="../assets/images/loading.gif"/>
    <p>登录中...</p>
  </div>
</template>

<script>

  import util from '../lib/util'

  export default {
    name: 'thirdLogin',

    data: function () {
      return {}
    },
    created: function () {
      this.thirdlogin();

    },
    methods: {
      thirdlogin: function () {

        let code = util.GetParameterUrl('code') || 0;
        let state = util.GetParameterUrl('state') || 0; //第三方平台id

        let source = '';
        if (window.sessionStorage.getItem('routerForm')) {
          source = window.sessionStorage.getItem('routerForm');

        }
        //获取用户信息
        util.ajax.post('/user/thirdlogin', util.jsonStringify({code, partner_id: state, source}))
          .then((res) => {
            //用户授权了手机号码
            if (res.code == '1202') {
              this.$router.push({path: 'BindingNumber'});
              return

            }
            this.$router.push({name: 'UserCenter'})
          })

      }


    }
  }
</script>
<style lang="scss">
  @import "@/assets/css/style.scss";

  .loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 4rem;
    text-align: center;
    font-size: 0.666666rem;
    img {
      width: 1.333333rem;
      height: 1.333333rem;
      margin-bottom: 0.4rem;
    }
  }
</style>
